home *** CD-ROM | disk | FTP | other *** search
RISC OS BBC BASIC V Source | 1994-05-15 | 4.6 KB | 189 lines |
- >!RunImage
- Program Test Program For Receiving User Messages
- init
- quit%:
- start of poll loop
- "Wimp_Poll",0,bk%
- reason%
- reason%
- 2 :
- "Wimp_OpenWindow",,bk%
- 3 :
- "Wimp_CloseWindow",,bk%
- 6 :
- button
- 9 :
- menuselect
- 17,18:
- message
- "Wimp_CloseDown"
- button
- bk%!8
- read button state
- bk%!12=-2
- 5
- if Menu pressed over iconbar, create menu
- 0
- "Wimp_CreateMenu",,menu%,!bk%-64,184
- bk%!12
-
- ,
- <SELECT> used on iconbar icon..
- !bk%= mainw%
- !(
- "Wimp_GetWindowState",,bk%
- bk%!28 = -1
- #$
- "Wimp_OpenWindow",,bk%
- menuselect
- button%
- "Wimp_GetPointerInfo",,bk%+256
- read button state
- ,+button%=bk%!264
- !bk%
- quit if item 1 chosen
- 0$ quit%=
-
- re-open menu if Adjust was pressed
- button%=1
- "Wimp_CreateMenu",,menu%:
- message
- msg$
- bk%!16
- 9G
- read message action code
- 0 :quit%=
- :
- quit if Quit message received
- &43B00
- <
- msg$ =
- string(bk% + 20)
- >
- msg$,8) = "Proggy2:"
- msg$ =
- msg$,9)
- @,
- shell_IconPutData(mainw%,0,msg$,
- string(a%)
- convert a null-terminated string into CR-terminated
- ?a%<>0
- a$+=
- ?a%:a%+=1
- bk% 2000,menu% 75,ind% 2000,name% 11
- quit%=0:name$="Proggy2"
- err%=0
- "OS_ReadVarVal","Proggy2$Dir",bk%,255,0,3
- ,,i%
- bk%?i%=13:dir$=$bk%
- "Wimp_Initialise",200,&4B534154,name$
- error:
- "Wimp_OpenTemplate",,dir$+".Templates"
- i%=ind%
- infohan%=
- create("InfoBox")
- mainw% =
- create("mainw")
- "Wimp_CloseTemplate"
- Z%!bk%=-1:bk%!4=0:bk%!8=0:bk%!12=68
- [/bk%!16=68:bk%!20=&3002:$(bk%+24)="!Proggy2"
- "Wimp_CreateIcon",,bk%
- setupmenu(menu%)
- setupmenu(m%)
- $m%,num%:len%=
- ($m%)-2
- b!m%!12=&70207:m%!20=44:m%!24=0
- m%+=28:
- i%=1
- num%
- !m%=-&80*(i%=num%):
- m%!4
- e# m%!8=&7009021:
- a$:$(m%+12)=a$
- a$>len% len%=
- m%+=24
- :menu%!16=16*(len%+1)
- create(a$)
- $name%=a$
- "Wimp_LoadTemplate",,bk%,i%,ind%+2000,-1,name%,0
- ,,i%
- "Wimp_CreateWindow",,bk%
- handle%
- =handle%
- error
- report(
- $+" - internal error code "+
- "Wimp_CloseDown"
- report(a$,x%)
- !bk%=1:$(bk%+4)=a$+
- "Wimp_ReportError",bk%,x%,name$
- Proggy2,2,infohan%,Info,-1,Quit
- --- Memory Management Routines ----------------------------------------
- _heap_get(size%)
- ptr%,heap%,flags%
- Returns pointer to new memory block unless claim fails
- in which case -1 is returned
- First find start address of RMA..
- "OS_ReadDynamicArea",1
- heap%
- Now claim memory, trapping errors by using X form of SWI..
- "XOS_Module",6,,,size%
- ,,ptr%;flags%
- If error occured return -1, else return address of allocated
- block
- (flags%
- ptr% = -1
- = ptr%
- _heap_release(
- ptr%)
- maxfree%,nrpages%,flags%
- Returns 0 if block released OK
- Returns -1 if operation failed (i.e. block doesn't exist)
- "XOS_Module",7,,ptr%
- ;flags%:
- Free the block
- (flags%
- 1) = 0
- Block was released successfully...
- ptr% = 0
- Error occured trying to free the block, return -1 to signal to the
- program that something went wrong (normally the program would ignore
- this anyway)
- ptr% = -1
- shell_IconPutData(whandle%,ihandle%,data$,redraw)
- blk%,old_str$
- 4old_str$ =
- shell_IconGetData(whandle%,ihandle%)
- data$ <> old_str$
- blk%=
- _heap_get(40)
- blk%!0 = whandle%
- blk%!4 = ihandle%
- "Wimp_GetIconState",,blk%
- (blk%!24
- (1<<8)) <> 0
- 2
- data$ > blk%!36
- 99,"Icon overflow!"
- $(blk%!28) = data$
- ! $(blk% + 28) =
- data$,11)
- redraw <> 0
- blk%!8 = 0:blk%!12 = 0
- $
- "Wimp_SetIconState",,blk%
- _heap_release(blk%)
- shell_IconGetData(whandle%,ihandle%)
- result$,icon_blk%
- icon_blk%=
- _heap_get(40)
- icon_blk%!0=whandle%
- icon_blk%!4=ihandle%
- "Wimp_GetIconState",,icon_blk%
- (icon_blk%!24
- (1<<8))<>0
- result$=$(icon_blk%!28)
- result$=$(icon_blk%+28)
- _heap_release(icon_blk%)
- =result$
-